package com.seng.ossservice.controller;

import com.seng.ossservice.utils.AliOSSUtils;
import com.seng.utilscommon.response.Result;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

@Api(value = "文件上传")
@RestController
@RequestMapping("/ossservice/tb-imge")
@CrossOrigin
public class FileController {
    @Autowired
    private AliOSSUtils aliOSSUtils;

    @ApiOperation(value = "上传图片文件到alibaba的OSS")
    @PostMapping("/upload")
    public Result upload(MultipartFile file) {
        String upload = aliOSSUtils.upload(file);
        return Result.ok().data("url",upload);
    }

}
